home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 5 / The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO / amiga / tempdemo.lha / ProgrammersInfo / DSKEL-XS.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-22  |  7.1 KB  |  236 lines

  1. /*
  2.                             DSKEL-XS v1.1
  3.  
  4.                        (Xpress User Stats DOOR)
  5.  
  6.                        1         2         3
  7.              (123456789012345678901234567890123456789)
  8. Conf Access : XX_X____X___s__sX______X______________X
  9. Caller Num. : 100888
  10. 1st Date On : 22 Apr 91
  11. Lst Date On :  7 Mar 92
  12. Security Lv : 255
  13. # Times On  : 1123        Today : 4
  14. Msgs Posted : 1500        Today : 0
  15. File Ratio  : Disabled
  16. Byte Ratio  : Disabled
  17. # Downloads : 71          Today : 0
  18. # Uploads   : 85          Today : 0
  19. Bytes DL'd  : 137936061   Today : 39994
  20. Bytes UL'd  : 8089329     Today : 4433
  21. Online Baud : 14400
  22. Screen Clear: On
  23. Time Bar    : Off
  24. Bytes Avail : 3000000
  25.  
  26.  
  27. */
  28. //**********************
  29. //*****  Includes  *****
  30. //**********************
  31.  
  32. #include <proto/all.h>
  33. #include <stdio.h>
  34. #include <time.h>
  35.  
  36. #include <string.h>
  37. #include <tempest/headers.h>
  38.  
  39. //********************************
  40. //*****  Structures/Defines  *****
  41. //********************************
  42.  
  43. struct MyMessage
  44.  {
  45.   struct Message Msg;
  46.   struct User User;
  47.   char text[255];
  48.   char text1[255];
  49.   int car,Value,Data;
  50.   long LongValue;
  51.   int  IntValue;
  52.  };
  53.  
  54. struct User User;
  55. struct MsgPort *MyPort = NULL;
  56. struct MyMessage *msg;
  57.  
  58. void GetStr(char s[],int opt);
  59. int  DOORIO();
  60.  
  61. int  EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,first = 0;
  62. char DOOR_MSG [255],DOOR_MSG1[255],MyName[255],st[100];
  63.  
  64. //*****************************
  65. //*****  PL (Print Line)  *****
  66. //*****************************
  67.  
  68. void pl(fmt,a1,a2,a3)
  69. char *fmt;
  70. { char s[255]; sprintf(s,fmt,a1,a2,a3); DOOR_DATA=1; strcpy(DOOR_MSG,s); DOORIO(); }
  71.  
  72. //******************
  73. //*****  Main  *****
  74. //******************
  75.  
  76. main(int argc,char *argv[])
  77. {
  78.  char string[255],string1[255];
  79.  char Day[5],Month[5],Year[5];
  80.  register int x=1;
  81.  if(!DoorStart(argv[1])) { PutStr("DSKEL-XS v1.1 [Xpress Stats]\n"); exit(0); }
  82.  strcpy(string,User.MsgBase);
  83.  do
  84.   {
  85.    if(string[x] == 'N') string[x] = '_';
  86.    else if(string[x] == 'S') string[x] = 's';
  87.      else string[x] = 'X';
  88.    x++;
  89.   }
  90.  while(x < 40);
  91.  strmid(string,string1,2,39);
  92.  pl("\f\r\n                       1         2         3\r\n");
  93.  pl("             (123456789012345678901234567890123456789)\r\n");
  94.  pl("Conf Access : %s\r\n",string1);
  95. //********************************************************************
  96.  GetStr(string1,95);
  97.  pl("Caller Num. : %s\r\n",string1);
  98. //********************************************************************
  99.  strcpy(string,ctime(&User.Time_First_Called));
  100.  strmid(string,Month,5,3);
  101.  strmid(string,Day,9,2);
  102.  strmid(string,Year,23,2);
  103.  pl("1st Date On : %2s %s %s\r\n",Day,Month,Year);
  104. //********************************************************************
  105.  strcpy(string,ctime(&User.Time_Last_Logoff));
  106.  strmid(string,Month,5,3);
  107.  strmid(string,Day,9,2);
  108.  strmid(string,Year,23,2);
  109.  pl("Lst Date On : %2s %s %s\r\n",Day,Month,Year);
  110. //********************************************************************
  111.  pl("Security Lv : %d\r\n",User.Security);
  112. //********************************************************************
  113.  pl("# Times On  : %-5d       Today : %d\r\n",User.Total_Calls,User.Period_Calls);
  114. //********************************************************************
  115.  pl("Msgs Posted : %-5d       Today : %d\r\n",User.Total_Posts,User.Period_Posts);
  116. //********************************************************************
  117.  if(User.F_Ratio==0) strcpy(string1,"Disabled");
  118.  else                sprintf(string1,"%d/1",User.B_Ratio);
  119.  pl("File Ratio  : %s\r\n",string1);
  120. //********************************************************************
  121.  if(User.B_Ratio==0) strcpy(string1,"Disabled");
  122.  else                sprintf(string1,"%d/1",User.B_Ratio);
  123.  pl("Byte Ratio  : %s\r\n",string1);
  124. //********************************************************************
  125.  pl("# Downloads : %-4d        Today : %d\r\n",User.Total_DLFiles,User.Period_DLFiles);
  126. //********************************************************************
  127.  pl("# Uploads   : %-4d        Today : %d\r\n",User.Total_ULFiles,User.Period_ULFiles);
  128. //********************************************************************
  129.  pl("Bytes DL'd  : %-10ld  Today : %ld \r\n",User.Total_DLBytes,User.Period_DLBytes);
  130. //********************************************************************
  131.  pl("Bytes UL'd  : %-10ld  Today : %ld\r\n",User.Total_ULBytes,User.Period_ULBytes);
  132. //********************************************************************
  133.  GetStr(string1,19);
  134.  pl("Online Baud : %s\r\n",string1);
  135. //********************************************************************
  136.  if(User.UserBitsA & 0x00000400L) strcpy(string1,"On");
  137.  else                             strcpy(string1,"Off");
  138.  pl("Screen Clear: %s\r\n",string1);
  139. //********************************************************************
  140.  if(User.UserBitsA&0x00000008L) strcpy(string1,"On");
  141.  else                           strcpy(string1,"Off");
  142.  pl("Time Bar    : %s\r\n",string1);
  143. //********************************************************************
  144.  pl("Bytes Avail : %ld\r\n\r\n",User.Left_DLBytes);
  145. //********************************************************************
  146.  
  147. //*************************
  148. //*****  Close Stuff  *****
  149. //*************************
  150.  DOOR_DATA=99;
  151.  strcpy(DOOR_MSG,'\0');
  152.  DOORIO();
  153.  while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
  154.  if(MyPort) DeletePort(MyPort);
  155.  exit(0);
  156. }
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. //********************
  169. //*****  DoorIO  *****
  170. //********************
  171.  
  172. int DOORIO()
  173. {
  174.  struct MsgPort *HisPort;
  175.  struct MyMessage message;
  176.  int UPDATE;
  177.  if(EXIT_FLAG) return 0;
  178.  UPDATE=0;
  179.  HisPort = FindPort(st);
  180.  if(HisPort!=NULL)
  181.   {
  182.    message.Msg.mn_Node.ln_Type = NT_MESSAGE;
  183.    message.Msg.mn_Length = sizeof(message);
  184.    message.Msg.mn_ReplyPort = MyPort;
  185.    if(first)CopyMem(&User,&message.User,sizeof(struct User));
  186.    message.car   = 0;
  187.    message.Data  = DOOR_DATA;
  188.    message.Value = DOOR_VALUE;
  189.    message.IntValue = DOOR_VALUE1;
  190.    strcpy(message.text,DOOR_MSG);
  191.    strcpy(message.text1,DOOR_MSG1);
  192.    PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
  193.    Wait(1 << MyPort->mp_SigBit);
  194.    GetMsg(MyPort);
  195.    DOOR_DATA  = message.Data;
  196.    DOOR_VALUE = message.Value;
  197.    DOOR_VALUE1 = message.IntValue;
  198.    strcpy(DOOR_MSG,message.text);
  199.    strcpy(DOOR_MSG1,message.text1);
  200.    CopyMem(&message.User,&User,sizeof(struct User));
  201.    first=1;
  202.    UPDATE=0;
  203.    if(message.car) EXIT_FLAG=1;
  204.   }
  205.  return 0;
  206. }
  207.  
  208. //************************
  209. //*****  Door Start  *****
  210. //************************
  211.  
  212. DoorStart(char node[])
  213. {
  214.  struct MsgPort *HisPort;
  215.  EXIT_FLAG = 0;
  216.  sprintf(st,"%s:TEMPEST_DOOR",node);
  217.  HisPort = FindPort(st);
  218.  if(HisPort==NULL) return (FALSE);
  219.  sprintf(MyName,"%s:DOOR_PORT",node);
  220.  MyPort = CreatePort(MyName,0L);
  221.  if(MyPort==NULL)
  222.   {
  223.    PutStr("Cant open port");
  224.    return(int)FALSE;
  225.   }
  226.  DOORIO();
  227.  return (int)TRUE;
  228. }
  229.  
  230. //*********************************
  231. //*****  GetStr (Get String)  *****
  232. //*********************************
  233.  
  234. void GetStr(char s[],int opt)
  235. { DOOR_DATA=15; DOOR_VALUE=opt; strcpy(s,'\0'); DOORIO(); strcpy(s,DOOR_MSG); }
  236.